import request from '@/utils/request'

export function add(data) {
  return request({
    url: '/product/attr',
    method: 'post',
    data
  })
}

export function del(id) {
  return request({
    url: '/product/attr/' + id,
    method: 'delete'
  })
}

export function edit(data) {
  return request({
    url: '/product/attr',
    method: 'put',
    data
  })
}

export function editSpuAttr(spuId, data) {
  return request({
    url: '/product/attr/' + spuId,
    method: 'put',
    data
  })
}

export function getAttr(id) {
  return request({
    url: '/product/attr/' + id,
    method: 'get'
  })
}

export function listAttr(params) {
  return request({
    url: '/product/attr/list/' + params.type + '/' + params.pageNum + '/' + params.pageSize,
    method: 'get',
    params
  })
}

export function listAttrAll(spuId) {
  return request({
    url: '/product/attr/base/listforspu/' + spuId,
    method: 'get'
  })
}

export default { add, edit, editSpuAttr, del, getAttr, listAttr, listAttrAll }
